[LINUX] console: ensure virtual console is disabled if mfn/evtchn
authorkfraser@ubuntu.eng.hq.xensource.com <kfraser@ubuntu.eng.hq.xensource.com>
Fri, 8 Sep 2006 21:49:00 +0000 (14:49 -0700)
committerkfraser@ubuntu.eng.hq.xensource.com <kfraser@ubuntu.eng.hq.xensource.com>
Fri, 8 Sep 2006 21:49:00 +0000 (14:49 -0700)
not provided.
Signed-off-by: Keir Fraser <keir@xensource.com>
linux-2.6-xen-sparse/drivers/xen/console/console.c
linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c

index b35a7ed304fe25f8def1b8667f0933289f03d05d..a45d21a69c388b950826fb873538a252930b0c72 100644 (file)
@@ -182,17 +182,18 @@ static struct console kcons_info = {
        .index  = -1,
 };
 
-#define __RETCODE 0
 static int __init xen_console_init(void)
 {
        if (!is_running_on_xen())
-               return __RETCODE;
+               goto out;
 
        if (is_initial_xendomain()) {
                if (xc_mode == XC_DEFAULT)
                        xc_mode = XC_SERIAL;
                kcons_info.write = kcons_write_dom0;
        } else {
+               if (!xen_start_info->console.domU.evtchn)
+                       goto out;
                if (xc_mode == XC_DEFAULT)
                        xc_mode = XC_TTY;
                kcons_info.write = kcons_write;
@@ -212,14 +213,15 @@ static int __init xen_console_init(void)
                break;
 
        default:
-               return __RETCODE;
+               goto out;
        }
 
        wbuf = alloc_bootmem(wbuf_size);
 
        register_console(&kcons_info);
 
-       return __RETCODE;
+ out:
+       return 0;
 }
 console_initcall(xen_console_init);
 
@@ -247,7 +249,9 @@ void xencons_force_flush(void)
        int sz;
 
        /* Emergency console is synchronous, so there's nothing to flush. */
-       if (is_initial_xendomain())
+       if (!is_running_on_xen() ||
+           is_initial_xendomain() ||
+           !xen_start_info->console.domU.evtchn)
                return;
 
        /* Spin until console data is flushed through to the daemon. */
@@ -582,7 +586,11 @@ static int __init xencons_init(void)
        if (xc_mode == XC_OFF)
                return 0;
 
-       xencons_ring_init();
+       if (!is_initial_xendomain()) {
+               rc = xencons_ring_init();
+               if (rc)
+                       return rc;
+       }
 
        xencons_driver = alloc_tty_driver((xc_mode == XC_SERIAL) ?
                                          1 : MAX_NR_CONSOLES);
index 8a16e525774957da279c88727c4fec0863fbfd5e..e963ac95d7d358e1a6388b57f044880c910b193d 100644 (file)
@@ -110,24 +110,26 @@ static irqreturn_t handle_input(int irq, void *unused, struct pt_regs *regs)
 
 int xencons_ring_init(void)
 {
-       int err;
+       int irq;
 
        if (xencons_irq)
                unbind_from_irqhandler(xencons_irq, NULL);
        xencons_irq = 0;
 
-       if (!xen_start_info->console.domU.evtchn)
-               return 0;
+       if (!is_running_on_xen() ||
+           is_initial_xendomain() ||
+           !xen_start_info->console.domU.evtchn)
+               return -ENODEV;
 
-       err = bind_evtchn_to_irqhandler(
+       irq = bind_evtchn_to_irqhandler(
                xen_start_info->console.domU.evtchn,
                handle_input, 0, "xencons", NULL);
-       if (err <= 0) {
-               printk(KERN_ERR "XEN console request irq failed %i\n", err);
+       if (irq < 0) {
+               printk(KERN_ERR "XEN console request irq failed %i\n", irq);
                return err;
        }
 
-       xencons_irq = err;
+       xencons_irq = irq;
 
        /* In case we have in-flight data after save/restore... */
        notify_daemon();